<template>
	<w-container>
		<view class="pa-16">
			<view @click="toPage(item)" v-for="(item,index) in list" :key="item.id" class="bg-color-white br-12 pa-12 flex flex-ai-start mb-16">
				<w-image :src="item.admin_avatar" :width="40" :height="40" :radius="40"></w-image>
				<view class="flex flex-dir-col ml-12">
					<view class="font-w-500 mb-4">{{ item.title }}</view>
					<view style="color: #757575;" class="font-size-13 text-overflow-2">{{ item.content }}</view>
					<view class="flex flex-ai-center flex-w mt-12" style="gap: 20rpx;">
						<w-image @click.native.stop="bigImage(item.images,i)" v-for="(p,i) in item.images && item.images.split(',')" :key="i" :src="p" :width="80" :height="80" radius="8"></w-image>
					</view>
					<view class="flex flex-ai-center mt-12 flex-js-sb w-100">
						<view class="font-color-666 font-size-12">{{ item.create_time|formatDate }}</view>
						<view @click.stop="shareInfo(item)" class="flex flex-ai-center">
							<w-icon class="share"></w-icon>
							<view class="font-color-666 font-size-12">分享</view>
						</view>
					</view>
				</view>
			</view>
			<w-loading style="padding: 32rpx 0" :type="loadingType" emptyType="search" emptyTop="60"></w-loading>
		</view>
	</w-container>
</template>

<script>
	import {
		getWallList
	} from '@/api/notice/index.js'
	export default {
		data() {
			return {
				type:1,
				loadingType:'none',
				page:1,
				list:[]
			}
		},
		onLoad({type = 1}){
			this.type = type
			this.getList()
		},
		onShow() {
			// if(!this.list.length) {
			// 	this.loadingType = 'none'
			// 	this.page = 1
			// 	this.list = []
			// 	this.getList()
			// }
		},
		onPullDownRefresh() {
			this.loadingType = 'none'
			this.page = 1
			this.list = []
			this.getList()
		},
		onReachBottom() {
			if(this.loadingType == 'nomore') return
			this.page++
			this.getList()
		},
		methods: {
			toPage(item){
				uni.navigateTo({
					url:`/pages/superSpeak/detail?id=${item.id}`
				})
			},
			async getList(){
				this.loadingType = 'loading'
				if(this.type == 2) {			
					setTimeout(() => {
						 this.loadingType = 'empty'
						 uni.stopPullDownRefresh()
					},1500)
					return
				}
				const { data,code } = await getWallList({
					page:this.page
				})
				uni.stopPullDownRefresh()
				if(code != 1) return
				this.page = data.current_page
				if(this.page == 1 && data.total == 0) return this.loadingType = 'empty'
				this.list = this.list.concat(data.data)
				if(data.last_page == data.current_page) this.loadingType = 'nomore'
			},
			bigImage(URLS,I){
				let urls = URLS.split(',')
				urls = urls.map(item => this.$ossUrl + item)
				uni.previewImage({
					urls,
					current:I
				})
			},
			shareInfo(info){
				uni.setClipboardData({
					data:`${this.$ossUrl}/#/pages/superSpeak/detail?id=${info.id}`
				})
			}
		}
	}
</script>

<style>

</style>
